# Set the working directory to the project folder. 
project_folder <- "."
setwd(project_folder)
library(Seurat)
library(ggplot2)
library(ggalluvial)
library(grid)
library(forcats)
library(see)
library(dplyr)
library(gghalves)
library(viridis)
library(stringr)
library(kableExtra)
cols2_2 <- c(`0 CD8+ Eff mem (EM)` = "#A6CEE3", `1 CD8+ Eff cytotox (Ecyt)` = "#1F78B4",
    `2 Early prolif: HMGN+/HMGB+/PCNA+ cells` = "#B2DF8A", `3 CD4+ Naive/SCM` = "#33A02C",
    `4 Early  prolif: MCM3/5/7+ PCNA+ cells` = "#FB9A99", `5 Late prolif: histones enriched MKI67+ cells` = "#E31A1C",
    `6 CD4+ Central/Effector memory (CM/EM)` = "#FDBF6F", `7 Ribosomal/Mitocondrial/Degradated cells` = "#FF7F00",
    `8 Late prolif: CDK+/CDC+/AURKA+ MIK67+ cells` = "#CAB2D6", `9 γδ Tcells` = "#6A3D9A")

Top10 genes

integrated.obj <- readRDS("integrated.obj.rds")

markers <- FindAllMarkers(integrated.obj, only.pos = TRUE, min.pct = 0.25, logfc.threshold = 0.25)

markers %>%
    group_by(cluster) %>%
    top_n(n = 10, wt = avg_log2FC) -> top10

DoHeatmap(subset(integrated.obj, downsample = 1000), features = unique(top10$gene),
    group.colors = cols2_2) + NoLegend()

DotPlot(integrated.obj, features = unique(top10$gene), cols = c("#0610C1", "#C2062F",
    "#C2062F")) + coord_flip() + RotatedAxis()

FeaturePlot(integrated.obj, features = unique(top10$gene))

Genes of interest

Genes from the DEG, Pablo selected the most important ones.

pablo_markers <- c("CCR7", "IL7R", "TCF7", "CD27", "SELL", "GZMK", "GZMA", "GNLY",
    "GZMH", "NKG7", "GZMB", "PRF1", "MCM7", "PCNA", "CD4", "CD8A", "CD8B", "CD95",
    "MKI67", "CDK1", "GZMM", "HIST1H4C", "HIST1H3B", "HIST1H1B", "HIST1H3C", "HIST1H2BF",
    "HIST1H1E", "HIST1H3F", "HIST1H2AG", "HIST1H2AL", "HIST1H2BH", "MTRNR2L12", "MTRNR2L8",
    "RPS2", "CCNB1", "CCNA2", "CCNA1", "CDC20", "HMGN2", "TRDV1", "TRGV8")

DoHeatmap(subset(integrated.obj, downsample = 1000), features = unique(pablo_markers)) +
    NoLegend()
DotPlot(integrated.obj, features = unique(pablo_markers), cols = c("#0610C1", "#C2062F",
    "#C2062F")) + coord_flip() + RotatedAxis()

Gamma delta genes

gd_markers <- c("ZFP36", "CCL4", "PRF1", "GNLY", "NKG7", "KLRF1", "FCGR3A", "TRGV8",
    "TRDV1", "TYROBP", "GZMA", "GZMB", "GZMH", "GZMK", "GZMM", "TRDV1", "TRGV8")

DoHeatmap(subset(integrated.obj, downsample = 1000), features = unique(gd_markers)) +
    NoLegend()

DoHeatmap(subset(integrated.obj, downsample = 1000), features = unique(gd_markers))

DotPlot(integrated.obj, features = unique(gd_markers), cols = c("#0610C1", "#C2062F",
    "#C2062F")) + coord_flip() + RotatedAxis()

Session Info

sessionInfo()
## R version 4.3.0 (2023-04-21)
## Platform: aarch64-apple-darwin20 (64-bit)
## Running under: macOS Ventura 13.4.1
## 
## Matrix products: default
## BLAS:   /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRblas.0.dylib 
## LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0
## 
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
## 
## time zone: Europe/Madrid
## tzcode source: internal
## 
## attached base packages:
## [1] grid      stats     graphics  grDevices utils     datasets  methods  
## [8] base     
## 
## other attached packages:
##  [1] kableExtra_1.3.4   stringr_1.5.0      viridis_0.6.3      viridisLite_0.4.2 
##  [5] gghalves_0.1.4     dplyr_1.1.2        see_0.7.5          forcats_1.0.0     
##  [9] ggalluvial_0.12.5  ggplot2_3.4.2      SeuratObject_4.1.3 Seurat_4.3.0      
## [13] knitr_1.43        
## 
## loaded via a namespace (and not attached):
##   [1] RColorBrewer_1.1-3     rstudioapi_0.14        jsonlite_1.8.4        
##   [4] magrittr_2.0.3         spatstat.utils_3.0-3   farver_2.1.1          
##   [7] rmarkdown_2.21         vctrs_0.6.2            ROCR_1.0-11           
##  [10] spatstat.explore_3.2-1 webshot_0.5.4          htmltools_0.5.5       
##  [13] sass_0.4.6             sctransform_0.3.5      parallelly_1.35.0     
##  [16] KernSmooth_2.23-21     bslib_0.4.2            htmlwidgets_1.6.2     
##  [19] ica_1.0-3              plyr_1.8.8             plotly_4.10.1         
##  [22] zoo_1.8-12             cachem_1.0.8           igraph_1.4.2          
##  [25] mime_0.12              lifecycle_1.0.3        pkgconfig_2.0.3       
##  [28] Matrix_1.5-4           R6_2.5.1               fastmap_1.1.1         
##  [31] fitdistrplus_1.1-11    future_1.32.0          shiny_1.7.4           
##  [34] digest_0.6.31          colorspace_2.1-0       patchwork_1.1.2       
##  [37] tensor_1.5             irlba_2.3.5.1          labeling_0.4.2        
##  [40] progressr_0.13.0       fansi_1.0.4            spatstat.sparse_3.0-1 
##  [43] httr_1.4.6             polyclip_1.10-4        abind_1.4-5           
##  [46] compiler_4.3.0         withr_2.5.0            highr_0.10            
##  [49] MASS_7.3-60            tools_4.3.0            lmtest_0.9-40         
##  [52] httpuv_1.6.11          future.apply_1.11.0    goftest_1.2-3         
##  [55] glue_1.6.2             nlme_3.1-162           promises_1.2.0.1      
##  [58] Rtsne_0.16             cluster_2.1.4          reshape2_1.4.4        
##  [61] generics_0.1.3         gtable_0.3.3           spatstat.data_3.0-1   
##  [64] tidyr_1.3.0            data.table_1.14.8      sp_1.6-0              
##  [67] xml2_1.3.4             utf8_1.2.3             spatstat.geom_3.2-1   
##  [70] RcppAnnoy_0.0.20       ggrepel_0.9.3          RANN_2.6.1            
##  [73] pillar_1.9.0           limma_3.56.1           later_1.3.1           
##  [76] splines_4.3.0          lattice_0.21-8         survival_3.5-5        
##  [79] deldir_1.0-6           tidyselect_1.2.0       miniUI_0.1.1.1        
##  [82] pbapply_1.7-0          gridExtra_2.3          svglite_2.1.1         
##  [85] scattermore_1.1        xfun_0.39              matrixStats_0.63.0    
##  [88] stringi_1.7.12         lazyeval_0.2.2         yaml_2.3.7            
##  [91] evaluate_0.21          codetools_0.2-19       tibble_3.2.1          
##  [94] cli_3.6.1              uwot_0.1.14            xtable_1.8-4          
##  [97] reticulate_1.28        systemfonts_1.0.4      munsell_0.5.0         
## [100] jquerylib_0.1.4        Rcpp_1.0.10            globals_0.16.2        
## [103] spatstat.random_3.1-5  png_0.1-8              parallel_4.3.0        
## [106] ellipsis_0.3.2         listenv_0.9.0          scales_1.2.1          
## [109] ggridges_0.5.4         leiden_0.4.3           purrr_1.0.1           
## [112] rlang_1.1.1            cowplot_1.1.1          rvest_1.0.3           
## [115] formatR_1.14